MacroProcessor<T> Class

Summary

Manages the processing of macros.

Syntax
C#
C++/CLI
public class MacroProcessor<T> 
generic<typename T> 
public ref class MacroProcessor  

Type Parameters

T
Type of data passed to the macro substitution delegates.

Remarks

Macros are defined as ${macro_name} in strings. This class looks for those tokens and calls the appropriate registered delegate to return a string. The MacroProcessor class has the following default macros when created:

Value Meaning
date Current date.
random_string Random string of specified link.
random_date Random date in the specified min/max date range.
empty Empty string.
random_time Random time offset from the specified time.
replace(value) Releases the tag with the specified value.
Example

This example adds two macros to the macro processor and process a string.

C#
using Leadtools.Dicom.Common.Anonymization; 
 
 
public void MacroProcessorSample() 
{ 
   MacroProcessor<object> processor = new MacroProcessor<object>(); 
 
   // 
   // add two macros to the macro processor 
   // 
   processor.Macros.Add("current_date", new MacroSubstitutionDelegate<object>(CurrentDateMacro)); 
   processor.Macros.Add("current_time", new MacroSubstitutionDelegate<object>(CurrentTimeMacro)); 
 
   // 
   // Process a macro string 
   // 
   Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}")); 
} 
 
private string CurrentDateMacro(object userData, string name, params object[] parameters) 
{ 
   return DateTime.Now.ToShortDateString(); 
} 
 
private string CurrentTimeMacro(object userData, string name, params object[] parameters) 
{ 
   return DateTime.Now.ToShortTimeString(); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom.Common Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.